<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <script>    
   //检索 
   function searchListForm() {
   	    var params = $("#searchForm").serialize();
        $.post("${ctx}/customenchase/single/cartonSelect",params,function(result) {
            // 回调函数赋值
            var h = $(callBackHtml(result)).find("#listHtml").html();
            $('#listHtml').html(h);
        }, 'html');
	}
            
	 //重置
	function clean() {
    	 $("#cartonName").val('');
		 searchListForm();
	}    
    
    //选择按钮事件
    function selectFunction(obj){
    	// 判断是否被选中
    	var bolSelected = $(obj).hasClass("trSelected");
    	if (bolSelected) {
    		$(obj).removeClass("trSelected");
    	} else {
    		$(obj).addClass("trSelected");
    	}
    }
        
    function selectCarton() {
    	//获取 iframe 数量 
    	var frLength = window.parent.frames.length;
    	//父画面下标 
    	var parentIndex = frLength-2;
    	var arr =  $("#listHtml").find(".trSelected").find(".subCartonId");
    	if ($(arr).length!=2) {
			tipParent("请选择一个小箱和一个大箱！");
			return;
		}
    	var html1 = $("#listHtml").find(".trSelected").find(".subCartonName")[0].innerHTML;
    	var html2 = $("#listHtml").find(".trSelected").find(".subCartonName")[1].innerHTML;
    	if (html1!="定制小箱-4"&&html2!="定制小箱-4") {
    		tipParent("请选择一个小箱和一个大箱！");
			return;
		}
    	var returnValue = '';
    	if(arr!=null && arr.length>0){
    	var arrList = new Array();
	    	$.each(arr, function(i, item){
	    		arrList.push($(this).text())
	    	});
	    	returnValue = arrList.join(",")
    	}
    	window.parent.frames[parentIndex].selectCartonCallBack(returnValue,0);
    	closeWin(); 
    }
    </script>
</head>
<body>
<form id="searchForm">
<div class="layerHeader clearfix" style="width: 650px">
	<p class="headerTitle"><spring:message code="cartonInfo_title" /></p>
	<div class="headerButton clearfix">
                <button type="button" onclick="searchListForm();"><spring:message code="commom_check" /></button>
                <button type="button" onclick="clean();"><spring:message code="common_reset" /></button>
                <button type="button" onclick="selectCarton()"><spring:message code="style_selectOK" /></button>
                <button type="button" onclick="closeWin();"><spring:message code="btn_cancle" /></button>
    </div>
</div>
<div class="listArea" style="width: 650px">
	<div class="listBg">
	    <div class="searchArea clearfix">
            <div class=" clearfix">
                <!-- 箱体名称 -->
                <div class="searchInp clearfix">
                    <p><spring:message code="enchase_show_cartonInfo_cartonName" /></p>
                    <input type="text" id="cartonName" name="cartonName">
                </div>
            </div>
        </div>
	
        <div class="tableArea tabBoxSm" id="listHtml">
            <div class="tableScroll tabSm" style="overflow: auto;height: 317px;width:565px;">
                <table cellpadding="0" class="tableHead " >
                    <thead>
                    <tr>
                        <th><p class="table-No"><spring:message code="enchase_show_cartonInfo_no" /></p></th>
                        <th><p style="width:140px;"><spring:message code="enchase_show_cartonInfo_cartonName" /></p></th>
                        <th><p style="width:70px;"><spring:message code="enchase_show_cartonInfo_length" /></p></th>
                        <th><p style="width:70px;"><spring:message code="enchase_show_cartonInfo_width" /></p></th>
                        <th><p style="width:70px;"><spring:message code="enchase_show_cartonInfo_height" /></p></th>
                        <th><p style="width:70px;"><spring:message code="enchase_show_cartonInfo_volume" /></p></th>
                        <th><p style="width:70px;"><spring:message code="enchase_show_cartonInfo_weight" /></p></th>
                    </tr>
                    </thead>
                </table>
                <table cellpadding="0" class="tableBody" >
                <c:if test="${not empty cartonInfo.cartonInfoList}">       
                    <tbody>
                    <c:forEach items="${cartonInfo.cartonInfoList}" var="cartonInfoSelect" varStatus="status">
                    <tr onclick="selectFunction(this)">
                        <td><p class="table-No">${status.index+1}</p></th>
                        <!-- 箱体名称 -->
                        <td><p style="width:140px;" class='subCartonName text_overflow' data-toggle='tooltip' title='${cartonInfoSelect.cartonName}'>${cartonInfoSelect.cartonName}</p></td>
                        <!-- 长 -->
                        <td><p style="width:70px;"  class='subCartonLength'><fmt:formatNumber value="${cartonInfoSelect.cartonLength}" pattern="#,##0.####"/></p></td>
                        <!-- 宽 -->
                        <td><p style="width:70px;" class='subCartonWidth'><fmt:formatNumber value="${cartonInfoSelect.cartonWidth}" pattern="#,##0.####"/></p></td>
                        <!-- 高 -->
                        <td><p style="width:70px;" class='subCartonHeight'><fmt:formatNumber value="${cartonInfoSelect.cartonHeight}" pattern="#,##0.####"/></p></td>
                        <!-- 体积 -->
                        <td><p style="width:70px;" class='subCartonVolume'><fmt:formatNumber value="${cartonInfoSelect.cartonVolume}" pattern="#,##0.####"/></p></td>
                        <!-- 箱重 -->
                        <td><p style="width:70px;" class='subCartonWeight'><fmt:formatNumber value="${cartonInfoSelect.cartonWeight}" pattern="#,##0.####"/></p></td>
                        <!-- 纸箱id -->
                        <td class="subCartonId none">${cartonInfoSelect.id}</td>
                      </tr> 
                      </c:forEach>
                      </tbody>
                </c:if>             
                </table>
            </div>
        </div>
    </div>
</div>
</form>
</body>
</html>